package com.ad.pet.app.account.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ad.pet.R;
import com.ad.pet.models.remote.account.order.PacketStatus;

import java.util.List;

/**
 * Created by SEELE on 2019/2/14.
 */

public class PacketInfoAdapter extends BaseQuickAdapter<PacketStatus, BaseViewHolder> {
    private OnItemConfirmLinstener mOnItemConfirmLinstener;
    String mType = "";
    public PacketInfoAdapter(@Nullable List<PacketStatus> data,String type) {
        super(R.layout.item_packet_status_layout, data);
        mType = type;
    }
    public PacketInfoAdapter(@Nullable List<PacketStatus> data) {
        super(R.layout.item_packet_status_layout, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, PacketStatus item) {
        TextView tvNumber = helper.getView(R.id.tv_number);
        TextView tvTime = helper.getView(R.id.tv_time);
        ImageView ivHead = helper.getView(R.id.iv_head);
        TextView tvTitle = helper.getView(R.id.tv_title);
        TextView tvAttribute = helper.getView(R.id.tv_attribute);
        TextView tvDeliverTime = helper.getView(R.id.tv_deliver_time);
        TextView tvTotal = helper.getView(R.id.tv_total);
        TextView tvConfirm = helper.getView(R.id.tv_confirm);
//        tvNumber.setText(mContext.getString(R.string.order_number)+item.getPg_id());
//        tvTime.setVisibility(View.GONE);
//        GlideUtil.load(mContext,item.getIcon(),ivHead);
//        String address = "<font color='#0000000'>"+mContext.getString(R.string.address)+"</font>"+item.getPg_shipping_country()+" "+item.getPg_shipping_state()+" "+item.getPg_shipping_city()+" "+item.getPg_deliver_area()+" "+item.getPg_shipping_address()+" "+item.getPg_shipping_name()+" "+item.getPg_shipping_phone()+"("+item.getPg_shipping_zip()+")";
//        tvTitle.setText(Html.fromHtml(address));
//        String method="<font color='#000000'>"+mContext.getString(R.string.delivery_method)+"</font>"+item.getPg_shipping_method();
//        tvAttribute.setText(Html.fromHtml(method));
//        String deliveryTime="<font color='#000000'>"+mContext.getString(R.string.delivery_time)+"</font>"+item.getPg_send_addtime();
//        tvDeliverTime.setText(Html.fromHtml(deliveryTime));
//        tvTotal.setText(mContext.getString(R.string.total)+item.getItem_total());
//        if ("3".equals(mType)){
//            if (item.getIs_comment()==0){
//                tvConfirm.setVisibility(View.VISIBLE);
//                tvConfirm.setText(mContext.getString(R.string.write_comment));
//            }else {
//                tvConfirm.setVisibility(View.GONE);
//            }
//
//        }else {
//            tvConfirm.setVisibility(View.VISIBLE);
//        }
        tvConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemConfirmLinstener.onConfirm(helper.getLayoutPosition());
            }
        });
    }

    public void setOnItemConfirmLinstener(OnItemConfirmLinstener onItemConfirmLinstener) {
        mOnItemConfirmLinstener = onItemConfirmLinstener;
    }

    public interface OnItemConfirmLinstener{
        void onConfirm(int position);
    }
}
